package com.blah.gwtgames.client;

import com.blah.gwtgames.client.sudoku.CellValue;
import com.blah.gwtgames.client.sudoku.Sudoku;
import com.blah.gwtgames.client.sudoku.SudokuSolver;
import com.blah.gwtgames.client.sudoku.service.SudokuService;
import com.blah.gwtgames.client.sudoku.service.SudokuServiceAsync;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Widget;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class TestPage implements EntryPoint
{
	final SudokuSolver solver = new SudokuSolver(9);
	Sudoku sudoku = null;
	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad()
	{
		Button button = new Button("Lick Me!");
		button.addClickListener(new ClickListener()
		{
			public void onClick(final Widget sender)
			{
				TestPage.this.addPuzzle();
			}				
		});
		RootPanel.get().add(button);
	}
	protected void addPuzzle()
	{
		if (sudoku != null)
		{
			sudoku.lockValues();
			solver.setPuzzle(sudoku);
			solver.solve();
		}
		
		sudoku = new Sudoku(3);
		RootPanel.get().add(sudoku);
	}

}
